Skip to content

[ci] Exclude previous-major packs from APIScan - #13876

Open
simonrozsival wants to merge 4 commits into
mainfrom
simonrozsival-apiscan-exclusions
Open

simonrozsival wants to merge 4 commits into
mainfrom
simonrozsival-apiscan-exclusions

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 324e9565eb346987cc6a86b0de94735ca7f1855b

Dimension Assessment Rationale
Change confidence 8/10 ↑ -getProperty returns 37.2.0-rc.2.84 locally.
↑ Replaying the recorded collect log through task-lib tl.match (win32) excludes all 215 previous-major files and keeps all 173 current ones, plus near-miss paths.
↑ The step now fails on an empty or malformed version, which would otherwise exclude every pack.
↑ Two code reviews found no issues in the net change.
↓ No live Windows nightly APIScan run yet.
Diagnosis confidence 9/10 ↑ 7 of 10 findings come only from the 37.2.0-rc.2.84 pack in collect logs 560/562.
↑ Identical signatures in nightly builds 16175170 and 16187926.
Evidence fit 7/10 ↑ Explains the binutils and libZipSharpNative findings.
↓ The 3 aapt2/NativeAOT findings remain, so the step will still fail until an exception is granted.

Context: 13e05fe

The main nightly "Fail Build on Guardian Issues" step in the API Scan job fails every night with 10 active APIScan results. The Collect Files for APIScan step copies every Microsoft.Android* pack under bin\$(XA.Build.Configuration)\dotnet\packs. That includes the previous-major workload (currently 37.2.0-rc.2.84), which is installed only for multi-targeting and is not produced by this build. Seven findings come only from that pack:

  • missingsymbols for the binutils/LLVM tools as.exe, ld.exe, llc.exe, llvm-mc.exe, llvm-objcopy.exe, llvm-strip.exe. These appeared after 13e05fe removed binutils from the current pack and stopped downloading their PDBs.
  • missingsymbols for libzipsharpnative-3-3.dll.

Because the copy is flattened with overwrite, aapt2.exe from the two packs also races, and the last copy wins.

Read $(AndroidNetPreviousVersion) from eng/Versions.props with the provisioned local dotnet msbuild -getProperty, and exclude Microsoft.Android*\$(AndroidNetPreviousVersion)\** from collection. This avoids duplicating the version pin in YAML. -getProperty prints an empty line and exits 0 for an undefined property, and an empty version would turn the exclusion into Microsoft.Android*\\**, which excludes everything. So the step fails unless the value is a single version string. The previous-major packs are scanned by their own release branch.

Not addressed

The 3 remaining findings still fail the step:

  • aapt2.exe missingsymbols and documentationnotfound: a Google prebuilt.
  • Microsoft.Android.Runtime.NativeAOT.dll documentationnotfound for log!__android_log_print: the Android NDK liblog API.

APIScan marks all of them notSuppressible: true, so Guardian signature suppressions are not a supported fix. An earlier suppression-file attempt was reverted on this branch. They need an APIScan/1ES exception decision, or, for aapt2.exe, removal from the scan inputs.

Validation

  • dotnet msbuild eng/Versions.props -nologo -getProperty:AndroidNetPreviousVersion → 37.2.0-rc.2.84
  • Pipeline YAML parses; git diff --check is clean.
  • Replayed all 388 copy operations recorded in nightly build 16187926, plus synthetic edge cases, through azure-pipelines-task-lib tl.match with win32 semantics (as CopyFiles@2 calls it):
    • 37.2.0-rc.2.84: the 215 Microsoft.Android.Sdk.Windows\37.2.0-rc.2.84 files are excluded. All 173 current files are retained, as are …\37.2.0-rc.2.840\…, a current-pack subdirectory named 37.2.0-rc.2.84, and dot-directories.
    • Empty version: all files are excluded. The new guard prevents this.
    • Unexpanded variable: nothing is excluded (fail-open).
  • The pwsh step returns 37.2.0-rc.2.84 locally and exits 1 for an undefined property or multi-line output.
  • Not validated: no live Windows APIScan or nightly run. A manual main nightly should show 3 active results and no 37.2.0-rc paths in the collect log.

simonrozsival and others added 3 commits December 2, 2026 11:34
The nightly scan collects the previous workload installed for multi-targeting as well as the packs produced by this build. This adds seven unrelated findings from removed binutils and libZipSharpNative, and overwrites duplicate scan inputs.

Evaluate AndroidNetPreviousVersion from eng/Versions.props with the provisioned SDK and exclude that version from collection, without duplicating its package pin in YAML.

Validation: dotnet msbuild eng/Versions.props -nologo -getProperty:AndroidNetPreviousVersion returned 37.2.0-rc.2.84; PowerShell version lookup passed; pipeline YAML parsed; minimatch replay of all 388 recorded copy operations excluded 215 previous-major files and retained all 173 current files; git diff --check passed. A live Windows APIScan run was not performed. The three remaining Guardian findings are marked notSuppressible and require a supported APIScan remediation rather than signature suppressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
After the previous-major packs are excluded, APIScan still reports
three findings that cannot be fixed in this repo:

  * aapt2.exe `missingsymbols` and `documentationnotfound`: aapt2 is a
    Google prebuilt, so Microsoft symbols are unavailable and its CRT
    imports come from Google's toolchain.
  * Microsoft.Android.Runtime.NativeAOT.dll `documentationnotfound`:
    `log!__android_log_print` is the Android NDK liblog API, not a
    Windows API.

Add signature-scoped suppressions (taken from the APIScan Logs
artifact of build 16187926; identical in 16175170) to
.gdn/apiscan/apiscan.gdnsuppress, and pass it to `PostAnalysis@2`.

Note: APIScan marks these SARIF results `notSuppressible: true`.
Guardian may ignore the suppressions; if it does, these need an
APIScan exception or must be removed from the scan inputs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This reverts commit e65f9fd.

APIScan marks all three remaining results `notSuppressible: true`.
Guardian therefore most likely ignores signature suppressions for them,
and the file would read as an approved exception that was never
granted. No dotnet repo has a working APIScan suppression precedent;
macios's PostAnalysis step is disabled with `condition: false`.

The aapt2.exe and NativeAOT liblog findings need a supported APIScan
remediation: an APIScan/1ES exception, or excluding the third-party
binary from scan inputs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 2, 2026 10:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active in-scope review issues remain; the three APIScan findings are outside this change’s scope, and live Windows nightly validation remains pending.

No open issues 🎉

What changed in this PR

Updates nightly APIScan collection to exclude previous-major .NET for Android packs installed for multi-targeting, keeping scan inputs focused on the current build.

Changes:

  • Reads the previous-major pack version from eng/Versions.props using the provisioned SDK.
  • Excludes matching packs without duplicating the version pin in YAML.

The three remaining APIScan findings are outside this change’s scope; live Windows nightly validation remains pending.

File Description
build-tools/​automation/​azure-pipelines-nightly.yaml Resolves the previous-major version and excludes its packs from APIScan collection.

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member

/azp run Xamarin.Android-PR

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

`dotnet msbuild -getProperty` prints an empty line and exits 0 when a
property is undefined. If `AndroidNetPreviousVersion` were ever renamed
or removed from eng/Versions.props, the exclusion would become
`Microsoft.Android*\\**`. That excludes every pack, so APIScan would
scan nothing and pass.

Trim the output and fail the step unless it is a single version string.

Validation: replayed all 388 paths from nightly 16187926's collect log
through azure-pipelines-task-lib `tl.match` (as used by CopyFiles@2)
with win32 semantics:
  * version 37.2.0-rc.2.84: excludes exactly the 215 files under
    Microsoft.Android.Sdk.Windows\37.2.0-rc.2.84 and keeps all 173 others.
  * empty version: excludes all 388 (the case this guard prevents).
  * unexpanded variable: excludes nothing.
The pwsh step returns 37.2.0-rc.2.84 locally and fails for an undefined
property or multi-line output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@PeppersMuse

Copy link
Copy Markdown

Reviewed the APIScan previous-major exclusion. What I checked:

  • AndroidNetPreviousVersion resolves via eng/Versions.props to 37.2.0-rc.2.84, which matches the guard regex, and the author verified the same value locally with dotnet msbuild -getProperty.
  • The guard matters: an empty version would turn the exclusion into Microsoft.Android*\\** and drop every pack from the scan, so failing the step on an empty or malformed value is the right fail-safe. A multi-line value also fails the regex.
  • The exclusion pattern sits after the inclusion pattern in the CopyFiles@2 Contents list, as required for ! exclusions, and the variable is set by the pwsh step in the same job that runs the copy.
  • The step reads the version with the provisioned local dotnet.exe (this is the Windows APIScan job), avoiding a second copy of the version pin in YAML.
  • Copilot's review reported no open issues, and I found nothing to add. The 3 remaining findings are explicitly out of scope in the description, so I did not treat them as issues with this change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants